package com.xn.app.muying.util;

import android.app.Activity;
import android.content.SharedPreferences;
import android.os.Environment;

import java.io.File;

/**
 * Created by gang.jin on 2016/5/24.
 */
public class Constants {
    public static final String LOGTAG="MuYing";

    public static final int REFRESH = 100;// 刷新
    public static final int LOAD = 101;// 加载
    public static final String SHAREDPREFERENCESNAME = "zhiku";
    public static final File CACHE = new File(Environment.getExternalStorageDirectory(), "/zhiku/Cache");
    public static final File Luyin = new File(Environment.getExternalStorageDirectory(), "/zhiku/luyin");

    //获取SharedPreferences里面的值
    public static String getStringByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        return preferences.getString(name, "");
    }

    public static int getIntByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        return preferences.getInt(name, 0);
    }

    public static boolean getBooleanByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        return preferences.getBoolean(name, false);
    }

    //设置SharedPreferences里面的值
    public static void setStringByName(Activity mActivity, String name, String value) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().putString(name, value).commit();
    }

    public static void setIntByName(Activity mActivity, String name, Integer value) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().putInt(name, value).commit();
    }

    public static void setBooleanByName(Activity mActivity, String name, Boolean value) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().putBoolean(name, value).commit();
    }
}
